<?php

namespace App\Admin\Controllers;

use App\Models\ZhuangXiu;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class ZhuangxiuController extends AdminController
{
    protected $title='装修报价';
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(ZhuangXiu::with('user'), function (Grid $grid) {
            $grid->model()->orderBy('id','desc');
            $grid->column('id')->sortable();
            $grid->export()->filename('装修表单');
            $grid->column('area','面积大小');
            $grid->column('kaijian','开间数');
            $grid->column('cenggao','层高');
            $grid->column('jinshen','进深');
            $grid->column('fengge','装修风格');
            $grid->column('yaoqiu','特殊要求');
            $grid->column('user.mobile','用户手机号');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
                $filter->like('user.mobile','用户手机号');
            });
            $grid->disableBatchActions();
            $grid->disableViewButton();
            $grid->disableCreateButton();
            $grid->disableActions();
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new ZhuangXiu(), function (Show $show) {
            $show->field('id');
            $show->field('area');
            $show->field('cenggao');
            $show->field('fengge');
            $show->field('jinshen');
            $show->field('kaijian');
            $show->field('user_id');
            $show->field('yaoqiu');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new ZhuangXiu(), function (Form $form) {
            $form->display('id');
            $form->text('area');
            $form->text('cenggao');
            $form->text('fengge');
            $form->text('jinshen');
            $form->text('kaijian');
            $form->text('user_id');
            $form->text('yaoqiu');
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
